const express = require('express');
const bodyParser = require('body-parser');
const homeRouter = require('./routes/home');
const loginRouter = require('./routes/login');
const newsRouter= require('./routes/news');
const uploadRouter = require('./routes/upload');
const path = require('path');
const app = express();

app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json())
// 使用ejs模板引擎
// 告诉 express  视图文件所在的目录
app.set('views', path.join(__dirname, 'views'));
// 告诉express使用什么模板引擎
app.set('view engine', 'ejs');
// 使用静态资源的中间件
app.use('/static', express.static(path.join(__dirname, 'public')))

//使用路由
app.use(homeRouter);
app.use(loginRouter);
app.use(newsRouter);
app.use(uploadRouter);
app.listen(9527, () => {
    console.log('start at port 9527');
})